package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.SensitiveDto;
import com.heima.model.wemedia.pojos.WmSensitive;
import com.heima.wemedia.service.WmSensitiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @projectName: heima-leadnews-project_training
 * @author: Tyoui
 * @description: 敏感词管理业务控制层
 * @date: 2023/8/2 9:05
 */
@RestController
@RequestMapping("/api/v1/sensitive")
public class WmSensitiveController {

    @Autowired
    private WmSensitiveService wmSensitiveService;

    /**
     * @param dto:
     * @return ResponseResult
     * @description 查询敏感词列表
     */
    @PostMapping("/list")
    public ResponseResult list(@RequestBody SensitiveDto dto) {
        return wmSensitiveService.list(dto);
    }

    /**
     * @param sensitive:
     * @return ResponseResult
     * @description 新增敏感词
     */
    @PostMapping("/save")
    public ResponseResult save(@RequestBody WmSensitive sensitive) {
        return wmSensitiveService.saveSensitives(sensitive);
    }

    /**
     * @param id:
     * @return ResponseResult
     * @description 删除敏感词
     */
    @DeleteMapping("/del/{id}")
    public ResponseResult delete(@PathVariable Integer id) {
        return wmSensitiveService.delete(id);
    }

    /**
     * @param sensitive:
     * @return ResponseResult
     * @description 修改敏感词
     */
    @PostMapping("/update")
    public ResponseResult update(@RequestBody WmSensitive sensitive) {
        return wmSensitiveService.updateSensitives(sensitive);
    }
}